using System;

namespace Mes.Production.Config
{
    /// <summary>
    /// API配置类
    /// </summary>
    public static class ApiConfig
    {
        /// <summary>
        /// 获取API基础URL
        /// </summary>
        /// <returns>API基础URL</returns>
        public static string GetApiBaseUrl()
        {
            try
            {
                var configValue = System.Configuration.ConfigurationManager.AppSettings["ApiBaseUrl"];
                //return !string.IsNullOrEmpty(configValue) ? configValue : "http://47.99.42.133:8000/production";
                //return !string.IsNullOrEmpty(configValue) ? configValue : "http://localhost:5050";
                return !string.IsNullOrEmpty(configValue) ? configValue : "http://10.223.8.8:5091";
            }
            catch
            {
                //return "http://47.99.42.133:8000/production";
                //return "http://localhost:5050";
                return "http://10.223.8.8:5091";
            }
        }

        /// <summary>
        /// 获取API超时时间（秒）
        /// </summary>
        /// <returns>超时时间</returns>
        public static int GetApiTimeout()
        {
            try
            {
                var configValue = System.Configuration.ConfigurationManager.AppSettings["ApiTimeout"];
                return int.TryParse(configValue, out int timeout) ? timeout : 30;
            }
            catch
            {
                return 30;
            }
        }
    }
}